package com.technology.education.ui.market.register

import android.os.Bundle
import com.technology.education.R
import com.technology.education.databinding.ActivityMarketRegisterBinding
import com.technology.education.ext.getMiddleColor
import com.technology.education.ui.common.login.ActivityLogin
import me.hgj.jetpackmvvm.base.activity.BaseVmDbActivity
import me.hgj.jetpackmvvm.ext.lifecycle.KtxActivityManger
import me.hgj.jetpackmvvm.util.get
import me.hgj.jetpackmvvm.util.startActivity

/**
 *@author:create by BZY
 *Date: 2022/2/24 17
 * 市场推广人员注册账号
 */
class ActivityRegister : BaseVmDbActivity<RegisterViewModel, ActivityMarketRegisterBinding>() {
    override fun initView(savedInstanceState: Bundle?) {
        mViewModel.type = intent.get("type", 0) ?: 0
        mDatabind.vm = mViewModel
        mDatabind.toolBar.tvTitle.text = ""
        mDatabind.tvReferral.apply {
            text = getMiddleColor("没有邀请码？", "联系客户", "获取邀请码", getColor(R.color.theme_color))
            setOnClickListener {

            }
        }
        mDatabind.tvLogin.apply {
            text = getMiddleColor("我有账号？立即去", "登录", "", getColor(R.color.theme_color))
            setOnClickListener {
                KtxActivityManger.finishAllActivity()
                startActivity(ActivityLogin::class)
            }
        }
    }

    override fun showLoading(message: String) {
    }

    override fun dismissLoading() {
    }

    override fun createObserver() {
        mViewModel.result.observe(this) {
            if (it) {
                onBackPressed()
            }
        }
    }
}